export function preloadImage(list = []) {
    const promises = list.map(vo => {
        return new Promise((resolve, reject) => {
           let img = new Image();
           img.src = vo;
           if (img.complete) {
               resolve(img);
           } else {
               img.onload = function(){
                   resolve(img);
               }
               img.onerror = function() {
                   reject('fail to load image');
               }
           }
        });
    });
    return Promise.all(promises);
};

export function getGuid() {
    const target = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
    return target.replace(/[x]/g, (c) => {
        const r = Math.random() * 16 | 0,
            v = c === 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
    });
}
